fix(flow-chat): centre single-line user messages in their bubble - #1953
Merged
bobleer merged 1 commit intoAug 1, 2026
Merged
Conversation
The action cluster keeps its 28px layout box while idle at `opacity: 0`, so it outgrew the ~22px first-line box and became the tallest item in the flex row. With `align-items: flex-start` that pinned a single-line message to the top of an over-tall row, leaving 14.24px below the text against 8.36px above it, and the text read as sitting above the bubble's centre. - collapse the action cluster to the first-line box so the text drives the row height and the bubble's symmetric vertical padding is restored - centre the buttons on the first line (previously 2.94px low) - derive the line box from the existing typography tokens so the fix follows the user's font-size preference - fold the `--failed` variant's one-sided margin into the shared rule, which also removes its residual 2.33px offset Multi-line messages are unaffected: their text already exceeded the cluster height, so bubble heights there are unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A user message that fits on one line renders with its text sitting above the bubble's vertical centre. This centres it by stopping the idle action buttons from inflating the row.
The action cluster (copy / edit / rollback) keeps its 28px layout box while idle at
opacity: 0— opacity hides the buttons but does not remove their layout box. That made the cluster taller than the ~22px first-line box and therefore the tallest item in.user-message-item__main, whosealign-items: flex-startthen pinned a single-line message to the top of an over-tall row.Type and Areas
Type: bug fix (UI/UX)
Areas: web UI (
flow_chat— user message bubble)Motivation / Impact
Single-line messages such as
继续looked visibly off-centre: 8.36px of space above the text against 14.24px below it, inside a bubble whose padding is a symmetric0.46rem. Multi-line messages never showed the problem, because two lines of text (44.23px) already exceed the 28px cluster and the text was driving the row height again — which is why this only reproduced on short messages.The fix collapses the action cluster to the first-line box, so the text drives the row height and the bubble's symmetric padding is restored. Hit-target size is unchanged (still 28px); the cluster simply stops contributing extra height. The line box is derived from the existing typography tokens rather than hardcoded, so the correction follows the user's font-size preference in both directions.
Two related improvements come along with it:
--failedvariant already applied this idea but only as amargin-top, leaving a residual 2.33px offset. It now re-points the shared--user-message-line-boxvariable and reuses the base rule.Worth noting as corroboration: the image-export path already excludes
.user-message-item__actionsfrom the render (ExportImageButton.tsx), so exported conversation images were already tight and centred. The live UI was the odd one out.Verification
Measured in-browser against the real compiled stylesheet —
UserMessageItem.scssand theapply-design-tokensmixin compiled together withsass, then applied to the component's real DOM structure — rather than reasoning from the source. "Before" was produced by neutralising only the new margins on that same page.Also checked with the fix applied: buttons stay inside the bubble (5.42px clearance top and bottom, no clipping), and the pending-steering tag and timestamp variants remain correctly aligned.
Commands run:
pnpm run type-check:web— passespnpm exec vitest run src/flow_chat/components/modern src/app/startup/startupPerformanceContract.test.ts— 27 files, 260 tests, all passingnode scripts/audit-theme-colors.mjs— exit 0node scripts/validate-theme-visual-contract.mjs— 10/10 required surfaces coveredReviewer Notes
CSS-only change; no component, markup, or behaviour changes. No new colours, so the theme governance baselines are untouched.
The formula
calc((var(--user-message-line-box) - 28px) / 2)is deliberately signed: if a larger font preference makes the line box exceed 28px, the margins turn positive and the cluster still matches the first-line box exactly, so the centring holds in both directions.AI-assisted change. Testing level: fully tested for the layout behaviour it targets (measured before/after plus the focused suites above); not exercised in a running desktop session.
Checklist